home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_3.5 / Examples / Printer / PrintHook / printhook.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-30  |  1.8 KB  |  79 lines

  1. /*
  2.  * COPYRIGHT:
  3.  *
  4.  *   Unless otherwise noted, all files are Copyright (c) 1999 Amiga, Inc.
  5.  *   All rights reserved.
  6.  *
  7.  * DISCLAIMER:
  8.  *
  9.  *   This software is provided "as is". No representations or warranties
  10.  *   are made with respect to the accuracy, reliability, performance,
  11.  *   currentness, or operation of this software, and all use is at your
  12.  *   own risk. Neither Amiga nor the authors assume any responsibility
  13.  *   or liability whatsoever with respect to your use of this software.
  14.  */
  15.  
  16.  
  17. #include <devices/printer.h>
  18. #include <utility/hooks.h>
  19.  
  20. #include <clib/exec_protos.h>
  21.  
  22. static void readpixels(register __a0 struct Hook *hook,
  23.     register __a2 APTR object, register __a1 struct DRPSourceMsg *msg)
  24. {
  25.     LONG x, width = msg->width, r = msg->y << 16;
  26.     ULONG *buf = msg->buf;
  27.     for (x = 0; x < width; x++)
  28.         buf[x] = (r | x) ^ 0x00ffffff;
  29. }
  30.  
  31. struct Hook hook =
  32. {
  33.     { NULL, NULL },
  34.     (HOOKFUNC) readpixels,
  35.     NULL,
  36.     NULL
  37. };
  38.  
  39. void main()
  40. {
  41.     struct MsgPort *replyport;
  42.     struct IODRPTagsReq *ior;
  43.     static struct TagItem tags[] =
  44.     {
  45.         DRPA_SourceHook, (ULONG) &hook,
  46.         DRPA_AspectX, 1,
  47.         DRPA_AspectY, 1,
  48.         TAG_END
  49.     };
  50.  
  51.     if (replyport = CreateMsgPort())
  52.     {
  53.         if (ior = (struct IODRPTagsReq *) CreateIORequest(replyport,sizeof(*ior)))
  54.         {
  55.             if (!OpenDevice("printer.device",0,(struct IORequest *) ior, 0))
  56.             {
  57.                 ior->io_Command = PRD_DUMPRPORTTAGS;
  58.                 ior->io_Flags = 0;
  59.                 ior->io_Error = 0;
  60.                 ior->io_RastPort = NULL;
  61.                 ior->io_ColorMap = NULL;
  62.                 ior->io_Modes = 0;
  63.                 ior->io_SrcX = 0;
  64.                 ior->io_SrcY = 0;
  65.                 ior->io_SrcWidth = 256;
  66.                 ior->io_SrcHeight = 256;
  67.                 ior->io_DestCols = 256;
  68.                 ior->io_DestRows = 256;
  69.                 ior->io_Special = 0;
  70.                 ior->io_TagList = tags;
  71.                 DoIO((struct IORequest *) ior);
  72.                 CloseDevice((struct IORequest *) ior);
  73.             }
  74.             DeleteIORequest((struct IORequest *) ior);
  75.         }
  76.         DeleteMsgPort(replyport);
  77.     }
  78. }
  79.